package hpp.test;

import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;

/**
 * Created by hpp on 2017/8/22.
 */
public class Solution2 {


    static PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();

    public static void main(String[] args) {
        BinaryTreeNode root1=new BinaryTreeNode();
        BinaryTreeNode node1=new BinaryTreeNode();
        BinaryTreeNode node2=new BinaryTreeNode();
        BinaryTreeNode node3=new BinaryTreeNode();
        BinaryTreeNode node4=new BinaryTreeNode();
        root1.leftNode=node1;
        root1.rightNode=node2;
        node1.leftNode=node3;
        node1.rightNode=node4;
        root1.value=10;
        node1.value=5;
        node2.value=12;
        node3.value=4;
        node4.value=7;
//        System.out.println(countAbs(root1));
        int t,x,y;
        t=3; x=y=2; t=x++ | ++y;
        System.out.println(t);
        System.out.println(y);
    }


    private static int countAbs(BinaryTreeNode root){
        printQueueOrderBy(root);
        int min = 0;
        int max = 0;
//        System.out.println("size="+priorityQueue.size());
        int size = priorityQueue.size();
        for (int i = 0;i<size;i++){
            int tmp = priorityQueue.poll();
//            System.out.println("tmp=" + tmp);
            if (i==0)
                min = tmp;
            if (i==size-1)
                max = tmp;
        }
//        System.out.println("min=" + min + " max=" + max);
        return min>max?min-max:max-min;
    };


    public static void printQueueOrderBy(BinaryTreeNode root){

        if (root==null)
            return;
        Queue<BinaryTreeNode> queue=new LinkedList<>();
        queue.add(root);
        while(!queue.isEmpty()){
            BinaryTreeNode node=queue.poll();
//            System.out.print(node.value + " ");
            priorityQueue.add(node.value);
            if(node.leftNode!=null){
                queue.add(node.leftNode);
            }
            if(node.rightNode!=null){
                queue.add(node.rightNode);
            }
        }
    }

}


class BinaryTreeNode {
    public int value;
    public BinaryTreeNode leftNode;
    public BinaryTreeNode rightNode;
}